﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Applications.Command.Aquaculture;
using Traceability.App.Applications.Command.DeepProce;
using Traceability.App.Applications.Command.Enterprise;
using Traceability.App.Applications.Command.Health;
using Traceability.App.Applications.Command.IMage;
using Traceability.App.Applications.Command.Slaughter;
using Traceability.App.Applications.Command.TraceabilityManagement;
using Traceability.App.Applications.Command.TraceabilityManagement.Dto;
using Traceability.Domain.Entity;
using Traceability.Enum;

namespace Traceability.App.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {

        private readonly IMediator mediator;

        public ManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 修改图片
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpPost]
        public Task<ApiResult<int>> UpdataImages(UpIMageCommand request)
        {
            return mediator.Send(request);
            
        }

        //修改图片字段
        [HttpPost]
        public Task<ApiResult<ImageModel>> updateImagePbatch(UpdatebatchCommand request)
        { 
            return mediator.Send(request);
        
        }



        /// <summary>
        /// 深加工信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> UpdataDeep(UpdataDeepCommand request)
        { 
            
            return mediator.Send(request);
        }

        /// <summary>
        /// 添加深加工的信息 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddDeep(AddDeepCommand request)
        {

            return mediator.Send(request);
        }
        /// <summary>
        /// 获取深加工信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<DeepProcessingModel>>GetDeep(GetDeepCommand request)
        { 
            
            return mediator.Send(request);
        }

        /// <summary>
        /// 修改屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> UpdataSlaughter(UpdataSlaughterCommand request)
        { 
            return mediator.Send(request);
        }
        /// <summary>
        /// 展示屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<SlaughterModel>> GetSlaughter(GetshowSlaughterCommand request)
        { 
        
            return mediator.Send(request);
        }
        /// <summary>
        /// 添加屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddSlaught(AddSlaughterCommand request)
        { 
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改企业
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdataCompany(UpdataEnterpriseCommand request)
        { 
        
            return mediator.Send(request);
        }
        //添加企业信息
        [HttpPost]
        public Task<ApiResult<int>> AddEnter(AddEnterpriseCommand request)
        { 
            return mediator.Send(request);
        }

        /// <summary>
        /// 获取企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<EnterpriseModel>> GetCompany(EnterpriseshowCommand request)
        { 
        
            return  mediator.Send(request);
        }


            

        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> DelImage(UpdateImageCommand request)
        { 
            return mediator.Send(request);
        }

        /// <summary>
        /// 展示图片
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<ImageModel>>> GetImage([FromQuery]GetImageCommad request)
        {

            return mediator.Send(request);

            
        }
        /// <summary>
        /// 添加图片
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> AddImage(AddImageCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 修改健康信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdataHealth(UpdataHealthCommand request)
        { 
        
                return mediator.Send(request);

            
        }
        /// <summary>
        /// 保健信息删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> Delcommand(DelHealthCommand request)
        { 
            return mediator.Send(request);
        
        }
        /// <summary>
        /// 添加保健信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> AddHealth(AddHealthCommand request)
        { 

            return mediator.Send(request);
        
            
        }
        /// <summary>
        /// 获取养殖保健信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<HealthModel>>> GetHealth([FromQuery]GetHealthCommand request)
        { 
        
                return mediator.Send(request);

        }

        /// <summary>
        /// 商品基本信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<List<TraceabilityDto>>>> GetTraceability([FromQuery]TraceabilityGetAllCommand request)
        {

            return mediator.Send(request);
            
        }

        /// <summary>
        /// 商品信息添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> AddTraceability(AddTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 商品信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> UpdataTraceability(UpdataTraceabilityCommand request)
        {
            return mediator.Send(request);
            
        }
        /// <summary>
        /// 商品信息删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>>DelTraceability(DelTraceabilityCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 批量删除信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> DelList([FromQuery]DelListTraceabilityCommand request)
        {

            return mediator.Send(request);
        }

        /// <summary>
        /// 获取养殖信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<AquacultureModel>> GetAquaculture(GetshowCommand request)
        {

            return mediator.Send(request);
        }

        /// <summary>
        /// 添加养殖信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> AddAquaculture(AddAquacultureCommand request)
        {

            return mediator.Send(request);
        }
        /// <summary>
        /// 修改养殖信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> Updataculture(UpdataAquacultureCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request);
        }
    }
}
